package com.qingfeng.provide.service;

import com.qingfeng.core.dao.qingfeng.ComplainDao;
import com.qingfeng.core.dao.qingfeng.FileDao;
import com.qingfeng.core.entity.qingfeng.Complain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @description: 投诉
 * @author:LWY
 * @date: 2017/11/19 14:41
 * @modified:
 */
@Service
public class ComplainService {
    @Autowired
    ComplainDao complainDao;
    @Autowired
    FileDao fileDao;


    /**
     * 提交投诉
     *
     * @param user_id 用户id
     * @param task_id 任务id
     * @param type    投诉类型
     * @param message 投诉信息
     * @param files   文件集合
     */
    @Transactional
    public void submit(String user_id, String task_id, String type, String message, List<MultipartFile> files) {
        Complain complain = complainDao.submit(user_id, task_id, type, message);

        for (MultipartFile file : files) {
            String contentType = file.getContentType();
            String fileName = file.getOriginalFilename();
            //todo 上传文件
            String url = "";
            fileDao.save(1, 2, "", user_id, complain.getId(), url);
        }

    }
}
